
export namespace cm {
  export class Queue<T> {
    private _items: T[] = [];

    //入队
    enqueue(item: T) {
      this._items.push(item);
      let count = this.size();
    }

    //出队
    dequeue(): T | null {
      if (this._items.length > 0) {
        return this._items.splice(0, 1)[0];
      }
      else {
        return null;
      }
    }

    clearAll() {
      if (this._items.length) {
        this._items = [];
      }
    }

    size(): number {
      return this._items.length;
    }
  }
}